package cn.tedu.imop.basic.dao.repository.impl;

import cn.tedu.imop.basic.dao.mapper.AreaMapper;
import cn.tedu.imop.basic.dao.repository.AreaRepository;
import cn.tedu.imop.basic.entity.Area;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Repository
public class AreaRepositoryImpl implements AreaRepository {
    private AreaMapper areaMapper;
    public AreaRepositoryImpl(AreaMapper areaMapper) {
        this.areaMapper = areaMapper;
    }
    @Override
    public Map<Long, List<Area>> selectAreaList() {
        List<Area> list = areaMapper.selectList();
        return list.stream().collect(Collectors.groupingBy(Area::getParentId));
    }
}
